package com.itheima.health.controller;

import com.itheima.health.entity.Result;
import com.itheima.health.pojo.Setmeal;
import com.itheima.health.service.SetMealService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ：石破天
 * @date ：Created in 2022年06月07日
 * @description ：
 * @version: 1.0
 */
@RestController
@RequestMapping("/mobile/setmeal")
@Slf4j
@Api(tags = "手机端套餐接口")
public class MobileSetMealController {
    @Autowired
    private SetMealService setMealService;
    /**
     * 查询所有套餐
     * @return
     */
    @GetMapping("/getSetmeal")
    @ApiOperation("查询所有套餐")
    public Result getSetmeal(){
        List<Setmeal> list = setMealService.findAll();
        return Result.success(list);
    }

    /**
     * 根据id查询套餐详情
     * @param id
     * @return
     */
    @GetMapping("/findById")
    @ApiOperation("根据id查询套餐详情")
    public Result findById(@RequestParam Integer id){
        Setmeal setmeal= setMealService.findById(id);
        return Result.success(setmeal);
    }

}
